home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 13.7 KB | 473 lines | [TEXT/MPS ] |
- (*
- vidDrvrP4200(cmd,parameters) -- Driver for the Pioneer 4200 videodisc player. The cmd parameter specifies the
- function to be performed (p1 is the first parameter after cmd; p2 is the second, etc.):
-
- Command Function
- --------- --------
- chapter Return the chapter currently being displayed.
- control Execute a series of control functions. Each addition parameter is a keyword to be
- executed. If the keyword doesn't make sense here, pass it on to configureSPort.
- The following keywords are understood by the video driver:
- Keyword Function
- -------- --------
- init or reset Reset the player, configure the serial port (the baud rate is set to
- the highest available for the selected player).
- eject or reject Eject the disc from the player.
- audioOff Turn off both audio channels.
- audio1On Turn on audio channel 1.
- audio2On Turn on audio channel 2.
- stereoOn Turn on both audio channels.
- pictureOn/pictureOff Turn on/off the picture.
- framesOn/framesOff Turn on/off the display of frame numbers.
- frameMode Set player to frame number mode.
- chapterMode Set player to chapter number mode.
- timeMode Set player to time mode.
- defaultComm Set default communications settings for this player.
- extended Execute a function specific to the player. This player doesn't have any (yet).
- fps Set the frames per second for the next playVideo command to p1, which can be a number or
- one of "slowest", "slower", "slow", "normal", "fast", "faster", "fastest".
- frame Return the current frame number.
- name Return the long name of the player.
- play Start a sequence playing, from p1 to p2, which are frame numbers, chapter numbers, or times,
- depending upon the mode.
- scan Scan forward or backward, depending upong whether p1 is "forward" or "backward".
- search Search to frame, chapter, or time p1.
- sendCmd Send command p1 to the player and wait for an acknowlege.
- speeds Return the frames per second speeds allowed with this player.
- status Return the status of the play, which is a comma-separated list containing:
- Keyword Meaning
- -------- --------
- doorOpen or park or still or play State of player.
- CLV or CAV Type of disc.
- disc12inch or disc8inch Size of disc being played.
- side1 or side2 Side of disc being played.
- step Step p1 frames forward (or backward if it's negative), and do it p2 times.
- time Return the time of the frame currently being displayed, in 1/60ths of a second since the start
- of the disc.
- version Return the version of this player driver.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w vidDrvrP4200.p
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=8030 -sn Main=vidDrvrP4200 ∂
- vidDrvrP4200.p.o "{MPW}"Libraries:interface.o "{MPW}"PLibraries:PasLib.o
-
- Copyright © 1988 Apple Computer, Inc.
-
- 2/88 - Initial coding by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S vidDrvrP4200 } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- type
-
- Str31 = String[31];
-
- procedure vidDrvrP4200(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- vidDrvrP4200(paramPtr);
- end;
-
- procedure vidDrvrP4200(paramPtr: XCmdPtr);
-
- var returnValue: str255;
- pCount: integer;
- p1, p2: str255;
- str: str255;
- i: integer;
-
- {$I XCmdGlue.inc}
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(errMsg);
- exit(vidDrvrP4200);
- end;
-
- {$I VideoUtil.inc}
-
- procedure sendCmd(theCommand: str255);
- { Send a command to the player and wait for the ack. }
-
- begin
- SendCardMessage(Concat('sendSPort "',theCommand,'" & return'));
- EvalAndDispose('RecvUpTo("R",600,empty)');
- end;
-
- function chapter: str255;
- { Get the current chapter number from the player. }
-
- var theResult: str255;
-
- begin
- { Get the current chapter number... }
- SendCardMessage('sendSPort "?C" & return');
- theResult := EvalStr('recvUpTo(return,30,empty)');
- if length(theResult) <= 1 then chapter := 'noAnswer'
- else chapter := Copy(theResult,1,length(theResult)-1);
- end;
-
- procedure search(var toFrame: str255; blankSearch: boolean);
- { Search to a particular frame number, blanking if indicated. }
-
- begin
- if blankSearch then SendCmd('0 VD');
- SendCmd(Concat(toFrame,' SE'));
- if blankSearch then SendCmd('1 VD');
- end;
-
- procedure stop;
- { Stop the player. }
-
- begin
- SendCmd('ST');
- end;
-
- procedure control(var keywd: str255);
- { Handle a control command. }
-
- type
- audioModes = (off,oneOn,twoOn,stereo);
-
- var numberOfParms: integer;
- i: integer;
- parm: str255;
-
- procedure ejectPlayer;
- { Eject the disc. }
-
- begin
- { Send the appropriate eject command. }
- SendCmd('RJ OP');
- end;
-
- procedure audio(onOff: audioModes);
- { Set the audio mode. }
-
- begin
- { Send the appropriate audio channel command. }
- case onOff of
- off: SendCmd('0 AD');
- oneOn: SendCmd('1 AD');
- twoOn: SendCmd('2 AD');
- stereo: SendCmd('3 AD');
- end;
- end;
-
- procedure picture(onOff: boolean);
- { Turn the picture on or off. }
-
- begin
- { Send the appropriate picture command. }
- if onOff then SendCmd('1 VD')
- else SendCmd('0 VD');
- end;
-
- procedure frames(onOff: boolean);
- { Turn the frame number display on or off. }
-
- begin
- { Send the appropriate frame display command. }
- if onOff then SendCmd('1 DS 3 RA')
- else SendCmd('0 DS');
- end;
-
- procedure defaultComm;
- { Set the default communications configuration. }
-
- begin
- { Set the port configuration. }
- SendCardMessage('configureSPort baud4800,echoOff,editOff,linefeedOff,stripOff');
- end;
-
- procedure setMode(theMode: str255);
- { Set the frame/chapter/time mode. }
-
- begin
- SetStrGlobal('videoMode',theMode);
- if StringEqual(theMode,'chapterMode') then sendCmd('CH')
- else if StringEqual(theMode,'timeMode') then sendCmd('TM')
- else sendCmd('FR');
- end;
-
- procedure initPlayer;
- { Initialize the player. }
-
- begin
- { Empty out the globals. }
- SetStrGlobal('videoMode','');
- SetStrGlobal('blankNextVideo','');
- SetStrGlobal('videoSpeed','');
-
- { Send the reset command for this player. }
- SendCardMessage('sendSPort "SA" & return');
- { Wait for the ack. }
- EvalAndDispose('recvUpTo("R",1200,empty)');
-
- { Force it to stop. }
- stop;
-
- { Reset the player to known defaults. }
- setMode('');
- audio(stereo);
- frames(false);
- picture(true);
- end;
-
- begin
- if StringEqual(keywd,'init') or StringEqual(keywd,'reset') then initPlayer
- else if StringEqual(keywd,'eject') or StringEqual(keywd,'reject') then ejectPlayer
- else if StringEqual(keywd,'audioOff') then audio(off)
- else if StringEqual(keywd,'audio1On') then audio(oneOn)
- else if StringEqual(keywd,'audio2On') then audio(twoOn)
- else if StringEqual(keywd,'stereoOn') then audio(stereo)
- else if StringEqual(keywd,'pictureOn') then picture(true)
- else if StringEqual(keywd,'pictureOff') then picture(false)
- else if StringEqual(keywd,'framesOn') then frames(true)
- else if StringEqual(keywd,'framesOff') then frames(false)
- else if StringEqual(keywd,'defaultComm') then defaultComm
- else if StringEqual(keywd,'frameMode') then setMode('')
- else if StringEqual(keywd,'chapterMode') then setMode('chapterMode')
- else if StringEqual(keywd,'timeMode') then setMode('timeMode')
- else SendCardMessage(Concat('configureSPort ',keywd));
- end;
-
- function extended(var keywd: str255): str255;
- { Perform an extended command or function. }
-
- begin
- { No extended commands for this player. }
- end;
-
- procedure fps(var fpsKeywd: str255);
- { Set the frames per second. }
-
- begin
- { Default speed settings are fine. }
- end;
-
- function frame: str255;
- { Return the current frame number. }
-
- var str: str255;
-
- begin
- { Get the current frame number... }
- SendCardMessage('sendSPort "?F" & return');
- str := EvalStr('recvUpTo(return,30,empty)');
- if length(str) <= 1 then frame := 'noAnswer'
- else frame := Copy(str,1,length(str)-1);
- end;
-
- function name: str255;
- { Return the long name of the player. }
-
- begin
- name := 'Pioneer 4200';
- end;
-
- procedure play(var firstFrame,lastFrame,speed: str255; blankSearch: boolean);
- { Play a segment. }
-
- var lastFrameNum: longInt;
- startHere: boolean;
- playToLast: boolean;
- rev: boolean;
-
- begin
- { Figure out if we're playing to special (non-numeric markers). }
- startHere := StringEqual(firstFrame,'here');
- playToLast := StringEqual(lastFrame,'lastFrame');
- if playToLast then
- begin
- lastFrame := '54000';
- lastFrameNum := 54000;
- end
- else lastFrameNum := StrToLong(lastFrame);
-
- { Figure out whether we're playing forward or reverse. }
- rev := (not playToLast) and
- (((not startHere) and (lastFrameNum < StrToLong(firstFrame))) or (lastFrameNum = 0));
-
- { Search to the first frame. }
- if not startHere then search(firstFrame,blankSearch);
- { Set the speed. }
- SendCmd(Concat(LongToStr(2*StrToLong(speed)),' SP'));
- { Set the stopping point. }
- if (not playToLast) and (lastFrameNum <> 0) then SendCmd(Concat(lastFrame,' SM'));
- { Play it. }
- if rev then SendCmd('MR')
- else
- begin
- if StringEqual(speed,'30') then SendCmd('PL')
- else SendCmd('MF');
- end;
- end;
-
- function scan(scanForward: boolean): str255;
- { Scan forward (if scanForward is true) or backward. }
-
- begin
- if scanForward then SendCmd('NF')
- else SendCmd('NR');
- scan := '';
- end;
-
- procedure step(goForward: boolean);
- { Step one frame forward (if goForward is true) or backward. }
-
- begin
- if goForward then SendCmd('SF')
- else SendCmd('SR');
- end;
-
- function speeds: str255;
- { Return the valid speed for this player. }
-
- begin
- speeds := '1,2,3,4,5,6,7,8,9,10,15,20,30,60,90,120';
- end;
-
- function status: str255;
- { Return the current status of the player. }
-
- var statusString: str255;
- theResult: str255;
-
- begin
- SendCardMessage('sendSPort "?P" & return');
- statusString := EvalStr('recvUpTo(return,30,empty)');
- theResult := 'noAnswer';
- if length(statusString) >= 3 then
- if statusString[1] = 'P' then
- begin
- case statusString[3] of
- '0','1': theResult := 'park';
- '4', '9': theResult := 'play';
- '5','6': theResult := 'still';
- otherwise theResult := '';
- end;
- EvalAndDispose('recvUpTo(empty,10,empty)');
- SendCardMessage('sendSPort "?D" & return');
- statusString := EvalStr('recvUpTo(return,30,empty)');
- if length(statusString) >= 4 then
- begin
- theResult := Concat(theResult,',');
- case statusString[2] of
- '0': theResult := Concat(theResult,'CAV');
- '1': theResult := Concat(theResult,'CLV');
- end;
- theResult := Concat(theResult,',');
- case statusString[3] of
- '0': theResult := Concat(theResult,'disc12inch');
- '1': theResult := Concat(theResult,'disc8inch');
- end;
- theResult := Concat(theResult,',');
- case statusString[4] of
- '0': theResult := Concat(theResult,'side1');
- '1': theResult := Concat(theResult,'side2');
- end;
- end;
- end;
- status := theResult
- end;
-
- function time: str255;
- { Return the time for the current frame. }
-
- var theResult: str255;
-
- begin
- { Get the current frame time... }
- SendCardMessage('sendSPort "?T" & return');
- theResult := EvalStr('recvUpTo(return,30,empty)');
- time := EvalStr(Concat('HMSToTicks(',Copy(str,1,length(theResult)-1),'00'));
- end;
-
- function version: str255;
- { Return the version of this driver. }
-
- begin
- version := 'P4200 1.0';
- end;
-
- begin
- pCount := paramPtr^.paramCount;
-
- if pCount <= 0 then Fail('parameter count is not > 0');
-
- if pCount > 1 then GetStrParm(2,p1)
- else p1 := '';
- if pCount > 2 then GetStrParm(3,p2)
- else p2 := '';
-
- GetStrParm(1,str);
-
- returnValue := '';
-
- if StringEqual(str,'chapter') then returnValue := chapter
- else if StringEqual(str,'control') then
- begin
- for i := 2 to pCount do
- begin
- GetStrParm(i,str);
- control(str);
- end;
- end
- else if StringEqual(str,'extended') then returnValue := extended(p1)
- else if StringEqual(str,'fps') then fps(p1)
- else if StringEqual(str,'frame') then returnValue := frame
- else if StringEqual(str,'name') then returnValue := name
- else if StringEqual(str,'play') then
- begin
- GetStrGlobal('blankNextVideo',str);
- if str = '' then
- begin
- GetStrGlobal('videoSpeed',str);
- play(p1,p2,str,false);
- end
- else
- begin
- GetStrGlobal('videoSpeed',str);
- play(p1,p2,str,true);
- end;
- end
- else if StringEqual(str,'scan') then
- begin
- if length(p1) < 1 then returnValue := scan(true)
- else returnValue := scan(not ((p1[1] = 'b') or (p1[1] = 'B')));
- end
- else if StringEqual(str,'search') then
- begin
- GetStrGlobal('blankNextVideo',str);
- search(p1,str <> '');
- end
- else if StringEqual(str,'sendCmd') then sendCmd(p1)
- else if StringEqual(str,'step') then step(p1 = '1')
- else if StringEqual(str,'speeds') then returnValue := speeds
- else if StringEqual(str,'status') then returnValue := status
- else if StringEqual(str,'stop') then stop
- else if StringEqual(str,'time') then returnValue := time
- else if StringEqual(str,'version') then returnValue := version;
-
- { Return the result (if any). }
- paramPtr^.returnValue := PasToZero(returnValue)
- end;
-
- end.
-